using System;
using System.Collections;
using GeneXus.Utils;
using GeneXus.Resources;
using GeneXus.Application;
using GeneXus.Metadata;
using System.Data;
using System.Data.SqlClient;
using GeneXus.Data;
using com.genexus;
using GeneXus.Data.ADO;
using GeneXus.Data.NTier;
using GeneXus.Data.NTier.ADO;
using System.Runtime.Remoting;
using GeneXus.WebControls;
using GeneXus.Http;
using GeneXus.XML;
using GeneXus.Search;
using GeneXus.Encryption;
using GeneXus.Http.Client;
using System.Reflection;
using System.Xml.Serialization;
using System.Data.SqlTypes;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace GeneXus.Programs {
   [XmlSerializerFormat]
   [XmlRoot(ElementName = "Carne" )]
   [XmlType(TypeName =  "Carne" , Namespace = "Obligatorio" )]
   [Serializable]
   public class SdtCarne : GxSilentTrnSdt, System.Web.SessionState.IRequiresSessionState
   {
      public SdtCarne( )
      {
         context = new GxContext(  );
         DataStoreUtil.LoadDataStores( context);
         dsDefault = context.GetDataStore("Default") ;
         constructorCallingAssembly = Assembly.GetCallingAssembly() ;
         initialize();
         context.SetDefaultTheme("GeneXusXEv2");
      }

      public SdtCarne( IGxContext context )
      {
         this.context = context;
         constructorCallingAssembly = Assembly.GetCallingAssembly() ;
         initialize();
      }

      public void Load( short AV8CarneId )
      {
         IGxSilentTrn obj ;
         obj = getTransaction() ;
         obj.LoadKey(new Object[] {(short)AV8CarneId});
         return  ;
      }

      public IGxCollection GetMessages( )
      {
         short item = 1 ;
         IGxCollection msgs = new GxObjectCollection( context, "Messages.Message", "Genexus", "SdtMessages_Message", "GeneXus.Programs") ;
         SdtMessages_Message m1 ;
         IGxSilentTrn trn = getTransaction() ;
         msglist msgList = trn.GetMessages() ;
         while ( item <= msgList.ItemCount )
         {
            m1 = new SdtMessages_Message(context) ;
            m1.gxTpr_Id = msgList.getItemValue(item) ;
            m1.gxTpr_Description = msgList.getItemText(item) ;
            m1.gxTpr_Type = msgList.getItemType(item) ;
            msgs.Add(m1, 0);
            item = (short)(item+1) ;
         }
         return msgs ;
      }

      public override String ToXml( bool includeHeader ,
                                    String name ,
                                    String sNameSpace )
      {
         String s ;
         XmlSerializer xmls = new XmlSerializer(this.GetType(), sNameSpace);
         System.IO.MemoryStream stream = new System.IO.MemoryStream();
         System.Xml.XmlWriter xmlw = System.Xml.XmlWriter.Create(stream, new System.Xml.XmlWriterSettings() { OmitXmlDeclaration = !includeHeader});
         XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces();
         xmlns.Add(String.Empty, sNameSpace);
         xmls.Serialize( xmlw, this, xmlns);
         stream.Seek(0L, System.IO.SeekOrigin.Begin);
         System.IO.StreamReader sr = new System.IO.StreamReader(stream);
         s = sr.ReadToEnd();
         stream.Close();
         return s ;
      }

      public override void FromXml( String s ,
                                    String name )
      {
         SdtCarne deserialized ;
         if (s.Trim().Length == 0)
            return;
         XmlSerializer xmls = new XmlSerializer(this.GetType(),  "Obligatorio" );
         System.IO.StringReader sr = new System.IO.StringReader(s);
         deserialized = (SdtCarne)(xmls.Deserialize( sr)) ;
         sr.Close();
         SdtCarne obj ;
         obj = this ;
         obj.gxTpr_Carneid = deserialized.gxTpr_Carneid ;
         obj.gxTpr_Carnenombre = deserialized.gxTpr_Carnenombre ;
         obj.gxTpr_Periodistaid = deserialized.gxTpr_Periodistaid ;
         obj.gxTpr_Mode = deserialized.gxTpr_Mode ;
         obj.gxTpr_Initialized = deserialized.gxTpr_Initialized ;
         obj.gxTpr_Carneid_Z = deserialized.gxTpr_Carneid_Z ;
         obj.gxTpr_Carnenombre_Z = deserialized.gxTpr_Carnenombre_Z ;
         obj.gxTpr_Periodistaid_Z = deserialized.gxTpr_Periodistaid_Z ;
         return  ;
      }

      public override short readxml( GXXMLReader oReader ,
                                     String sName )
      {
         short GXSoapError = 1 ;
         sTagName = oReader.Name ;
         if ( oReader.IsSimple == 0 )
         {
            GXSoapError = oReader.Read() ;
            nOutParmCount = 0 ;
            while ( ( ( StringUtil.StrCmp(oReader.Name, sTagName) != 0 ) || ( oReader.NodeType == 1 ) ) && ( GXSoapError > 0 ) )
            {
               readOk = 0 ;
               if ( StringUtil.StrCmp2( oReader.LocalName, "CarneId") )
               {
                  gxTv_SdtCarne_Carneid = (short)(NumberUtil.Val( oReader.Value, ".")) ;
                  if ( GXSoapError > 0 )
                  {
                     readOk = 1 ;
                  }
                  GXSoapError = oReader.Read() ;
               }
               if ( StringUtil.StrCmp2( oReader.LocalName, "CarneNombre") )
               {
                  gxTv_SdtCarne_Carnenombre = oReader.Value ;
                  if ( GXSoapError > 0 )
                  {
                     readOk = 1 ;
                  }
                  GXSoapError = oReader.Read() ;
               }
               if ( StringUtil.StrCmp2( oReader.LocalName, "PeriodistaId") )
               {
                  gxTv_SdtCarne_Periodistaid = (short)(NumberUtil.Val( oReader.Value, ".")) ;
                  if ( GXSoapError > 0 )
                  {
                     readOk = 1 ;
                  }
                  GXSoapError = oReader.Read() ;
               }
               if ( StringUtil.StrCmp2( oReader.LocalName, "Mode") )
               {
                  gxTv_SdtCarne_Mode = oReader.Value ;
                  if ( GXSoapError > 0 )
                  {
                     readOk = 1 ;
                  }
                  GXSoapError = oReader.Read() ;
               }
               if ( StringUtil.StrCmp2( oReader.LocalName, "Initialized") )
               {
                  gxTv_SdtCarne_Initialized = (short)(NumberUtil.Val( oReader.Value, ".")) ;
                  if ( GXSoapError > 0 )
                  {
                     readOk = 1 ;
                  }
                  GXSoapError = oReader.Read() ;
               }
               if ( StringUtil.StrCmp2( oReader.LocalName, "CarneId_Z") )
               {
                  gxTv_SdtCarne_Carneid_Z = (short)(NumberUtil.Val( oReader.Value, ".")) ;
                  if ( GXSoapError > 0 )
                  {
                     readOk = 1 ;
                  }
                  GXSoapError = oReader.Read() ;
               }
               if ( StringUtil.StrCmp2( oReader.LocalName, "CarneNombre_Z") )
               {
                  gxTv_SdtCarne_Carnenombre_Z = oReader.Value ;
                  if ( GXSoapError > 0 )
                  {
                     readOk = 1 ;
                  }
                  GXSoapError = oReader.Read() ;
               }
               if ( StringUtil.StrCmp2( oReader.LocalName, "PeriodistaId_Z") )
               {
                  gxTv_SdtCarne_Periodistaid_Z = (short)(NumberUtil.Val( oReader.Value, ".")) ;
                  if ( GXSoapError > 0 )
                  {
                     readOk = 1 ;
                  }
                  GXSoapError = oReader.Read() ;
               }
               nOutParmCount = (short)(nOutParmCount+1) ;
               if ( readOk == 0 )
               {
                  context.sSOAPErrMsg = context.sSOAPErrMsg + "Error reading " + sTagName + StringUtil.NewLine( ) ;
                  GXSoapError = (short)(nOutParmCount*-1) ;
               }
            }
         }
         return GXSoapError ;
      }

      public override void writexml( GXXMLWriter oWriter ,
                                     String sName ,
                                     String sNameSpace )
      {
         if ( String.IsNullOrEmpty(StringUtil.RTrim( sName)) )
         {
            sName = "Carne" ;
         }
         if ( String.IsNullOrEmpty(StringUtil.RTrim( sNameSpace)) )
         {
            sNameSpace = "Obligatorio" ;
         }
         oWriter.WriteStartElement(sName);
         if ( StringUtil.StrCmp(StringUtil.Left( sNameSpace, 10), "[*:nosend]") != 0 )
         {
            oWriter.WriteAttribute("xmlns", sNameSpace);
         }
         else
         {
            sNameSpace = StringUtil.Right( sNameSpace, (short)(StringUtil.Len( sNameSpace)-10)) ;
         }
         oWriter.WriteElement("CarneId", StringUtil.Trim( StringUtil.Str( (decimal)(gxTv_SdtCarne_Carneid), 4, 0)));
         if ( StringUtil.StrCmp(sNameSpace, "Obligatorio") != 0 )
         {
            oWriter.WriteAttribute("xmlns", "Obligatorio");
         }
         oWriter.WriteElement("CarneNombre", StringUtil.RTrim( gxTv_SdtCarne_Carnenombre));
         if ( StringUtil.StrCmp(sNameSpace, "Obligatorio") != 0 )
         {
            oWriter.WriteAttribute("xmlns", "Obligatorio");
         }
         oWriter.WriteElement("PeriodistaId", StringUtil.Trim( StringUtil.Str( (decimal)(gxTv_SdtCarne_Periodistaid), 4, 0)));
         if ( StringUtil.StrCmp(sNameSpace, "Obligatorio") != 0 )
         {
            oWriter.WriteAttribute("xmlns", "Obligatorio");
         }
         oWriter.WriteElement("Mode", StringUtil.RTrim( gxTv_SdtCarne_Mode));
         if ( StringUtil.StrCmp(sNameSpace, "Obligatorio") != 0 )
         {
            oWriter.WriteAttribute("xmlns", "Obligatorio");
         }
         oWriter.WriteElement("Initialized", StringUtil.Trim( StringUtil.Str( (decimal)(gxTv_SdtCarne_Initialized), 4, 0)));
         if ( StringUtil.StrCmp(sNameSpace, "Obligatorio") != 0 )
         {
            oWriter.WriteAttribute("xmlns", "Obligatorio");
         }
         oWriter.WriteElement("CarneId_Z", StringUtil.Trim( StringUtil.Str( (decimal)(gxTv_SdtCarne_Carneid_Z), 4, 0)));
         if ( StringUtil.StrCmp(sNameSpace, "Obligatorio") != 0 )
         {
            oWriter.WriteAttribute("xmlns", "Obligatorio");
         }
         oWriter.WriteElement("CarneNombre_Z", StringUtil.RTrim( gxTv_SdtCarne_Carnenombre_Z));
         if ( StringUtil.StrCmp(sNameSpace, "Obligatorio") != 0 )
         {
            oWriter.WriteAttribute("xmlns", "Obligatorio");
         }
         oWriter.WriteElement("PeriodistaId_Z", StringUtil.Trim( StringUtil.Str( (decimal)(gxTv_SdtCarne_Periodistaid_Z), 4, 0)));
         if ( StringUtil.StrCmp(sNameSpace, "Obligatorio") != 0 )
         {
            oWriter.WriteAttribute("xmlns", "Obligatorio");
         }
         oWriter.WriteEndElement();
         return  ;
      }

      public override void ToJSON( )
      {
         AddObjectProperty("CarneId", (Object)(gxTv_SdtCarne_Carneid));
         AddObjectProperty("CarneNombre", (Object)(gxTv_SdtCarne_Carnenombre));
         AddObjectProperty("PeriodistaId", (Object)(gxTv_SdtCarne_Periodistaid));
         AddObjectProperty("Mode", (Object)(gxTv_SdtCarne_Mode));
         AddObjectProperty("Initialized", (Object)(gxTv_SdtCarne_Initialized));
         AddObjectProperty("CarneId_Z", (Object)(gxTv_SdtCarne_Carneid_Z));
         AddObjectProperty("CarneNombre_Z", (Object)(gxTv_SdtCarne_Carnenombre_Z));
         AddObjectProperty("PeriodistaId_Z", (Object)(gxTv_SdtCarne_Periodistaid_Z));
         return  ;
      }

      [  SoapElement( ElementName = "CarneId" )]
      [  XmlElement( ElementName = "CarneId"  )]
      public short gxTpr_Carneid
      {
         get {
            return gxTv_SdtCarne_Carneid ;
         }

         set {
            if ( gxTv_SdtCarne_Carneid != value )
            {
               gxTv_SdtCarne_Mode = "INS" ;
               this.gxTv_SdtCarne_Carneid_Z_SetNull( );
               this.gxTv_SdtCarne_Carnenombre_Z_SetNull( );
               this.gxTv_SdtCarne_Periodistaid_Z_SetNull( );
            }
            gxTv_SdtCarne_Carneid = (short)(value) ;
         }

      }

      [  SoapElement( ElementName = "CarneNombre" )]
      [  XmlElement( ElementName = "CarneNombre"  )]
      public String gxTpr_Carnenombre
      {
         get {
            return gxTv_SdtCarne_Carnenombre ;
         }

         set {
            gxTv_SdtCarne_Carnenombre = (String)(value) ;
         }

      }

      [  SoapElement( ElementName = "PeriodistaId" )]
      [  XmlElement( ElementName = "PeriodistaId"  )]
      public short gxTpr_Periodistaid
      {
         get {
            return gxTv_SdtCarne_Periodistaid ;
         }

         set {
            gxTv_SdtCarne_Periodistaid = (short)(value) ;
         }

      }

      [  SoapElement( ElementName = "Mode" )]
      [  XmlElement( ElementName = "Mode"  )]
      public String gxTpr_Mode
      {
         get {
            return gxTv_SdtCarne_Mode ;
         }

         set {
            gxTv_SdtCarne_Mode = (String)(value) ;
         }

      }

      public void gxTv_SdtCarne_Mode_SetNull( )
      {
         gxTv_SdtCarne_Mode = "" ;
         return  ;
      }

      public bool gxTv_SdtCarne_Mode_IsNull( )
      {
         return false ;
      }

      [  SoapElement( ElementName = "Initialized" )]
      [  XmlElement( ElementName = "Initialized"  )]
      public short gxTpr_Initialized
      {
         get {
            return gxTv_SdtCarne_Initialized ;
         }

         set {
            gxTv_SdtCarne_Initialized = (short)(value) ;
         }

      }

      public void gxTv_SdtCarne_Initialized_SetNull( )
      {
         gxTv_SdtCarne_Initialized = 0 ;
         return  ;
      }

      public bool gxTv_SdtCarne_Initialized_IsNull( )
      {
         return false ;
      }

      [  SoapElement( ElementName = "CarneId_Z" )]
      [  XmlElement( ElementName = "CarneId_Z"  )]
      public short gxTpr_Carneid_Z
      {
         get {
            return gxTv_SdtCarne_Carneid_Z ;
         }

         set {
            gxTv_SdtCarne_Carneid_Z = (short)(value) ;
         }

      }

      public void gxTv_SdtCarne_Carneid_Z_SetNull( )
      {
         gxTv_SdtCarne_Carneid_Z = 0 ;
         return  ;
      }

      public bool gxTv_SdtCarne_Carneid_Z_IsNull( )
      {
         return false ;
      }

      [  SoapElement( ElementName = "CarneNombre_Z" )]
      [  XmlElement( ElementName = "CarneNombre_Z"  )]
      public String gxTpr_Carnenombre_Z
      {
         get {
            return gxTv_SdtCarne_Carnenombre_Z ;
         }

         set {
            gxTv_SdtCarne_Carnenombre_Z = (String)(value) ;
         }

      }

      public void gxTv_SdtCarne_Carnenombre_Z_SetNull( )
      {
         gxTv_SdtCarne_Carnenombre_Z = "" ;
         return  ;
      }

      public bool gxTv_SdtCarne_Carnenombre_Z_IsNull( )
      {
         return false ;
      }

      [  SoapElement( ElementName = "PeriodistaId_Z" )]
      [  XmlElement( ElementName = "PeriodistaId_Z"  )]
      public short gxTpr_Periodistaid_Z
      {
         get {
            return gxTv_SdtCarne_Periodistaid_Z ;
         }

         set {
            gxTv_SdtCarne_Periodistaid_Z = (short)(value) ;
         }

      }

      public void gxTv_SdtCarne_Periodistaid_Z_SetNull( )
      {
         gxTv_SdtCarne_Periodistaid_Z = 0 ;
         return  ;
      }

      public bool gxTv_SdtCarne_Periodistaid_Z_IsNull( )
      {
         return false ;
      }

      public void initialize( )
      {
         gxTv_SdtCarne_Carnenombre = "" ;
         gxTv_SdtCarne_Mode = "" ;
         gxTv_SdtCarne_Carnenombre_Z = "" ;
         sTagName = "" ;
         IGxSilentTrn obj ;
         obj = (IGxSilentTrn)ClassLoader.FindInstance( "carne", "GeneXus.Programs.carne_bc", new Object[] {context}, constructorCallingAssembly) ;
         obj.initialize();
         obj.SetSDT(this, 1);
         setTransaction( obj) ;
         obj.SetMode("INS");
         return  ;
      }

      private short gxTv_SdtCarne_Carneid ;
      private short gxTv_SdtCarne_Periodistaid ;
      private short gxTv_SdtCarne_Initialized ;
      private short gxTv_SdtCarne_Carneid_Z ;
      private short gxTv_SdtCarne_Periodistaid_Z ;
      private short readOk ;
      private short nOutParmCount ;
      private String gxTv_SdtCarne_Mode ;
      private String sTagName ;
      private String gxTv_SdtCarne_Carnenombre ;
      private String gxTv_SdtCarne_Carnenombre_Z ;
      [NonSerialized()] private IGxDataStore dsDefault ;
      private Assembly constructorCallingAssembly ;
   }

   [DataContract(Name = "Carne", Namespace = "Obligatorio")]
   public class SdtCarne_RESTInterface : GxGenericCollectionItem<SdtCarne>, System.Web.SessionState.IRequiresSessionState
   {
      public SdtCarne_RESTInterface( ) : base()
      {
      }

      public SdtCarne_RESTInterface( SdtCarne psdt ) : base(psdt)
      {
      }

      [DataMember( Name = "CarneId" , Order = 0 )]
      [GxSeudo()]
      public short gxTpr_Carneid
      {
         get {
            return sdt.gxTpr_Carneid ;
         }

         set {
            sdt.gxTpr_Carneid = (short)(value) ;
         }

      }

      [DataMember( Name = "CarneNombre" , Order = 1 )]
      [GxSeudo()]
      public String gxTpr_Carnenombre
      {
         get {
            return sdt.gxTpr_Carnenombre ;
         }

         set {
            sdt.gxTpr_Carnenombre = (String)(value) ;
         }

      }

      [DataMember( Name = "PeriodistaId" , Order = 2 )]
      [GxSeudo()]
      public short gxTpr_Periodistaid
      {
         get {
            return sdt.gxTpr_Periodistaid ;
         }

         set {
            sdt.gxTpr_Periodistaid = (short)(value) ;
         }

      }

      public SdtCarne sdt
      {
         get {
            return (SdtCarne)Sdt ;
         }

         set {
            Sdt = value ;
         }

      }

      [OnDeserializing]
      void checkSdt( StreamingContext ctx )
      {
         if ( sdt == null )
         {
            sdt = new SdtCarne() ;
         }
      }

      [DataMember( Name = "gx_md5_hash", Order = 8 )]
      public string Hash
      {
         get {
            if ( StringUtil.StrCmp(md5Hash, null) == 0 )
            {
               md5Hash = (String)(getHash()) ;
            }
            return md5Hash ;
         }

         set {
            md5Hash = value ;
         }

      }

      private String md5Hash ;
   }

}
